<script type="text/javascript">
<if condition="C('ismobile') eq 1">width=$('.container').width() * 0.9;<else/>width=800;</if>
$("#dialog-select").dialog({
	autoOpen: false,
	modal: true,
	width: width,
	maxHeight:400,
	position: ["center",100],
	buttons: { 
        "Ok": function () {
			var item = $('input:radio[name="product_id"]:checked').val();
			var name = $('input:radio[name="product_id"]:checked').parent().next().html();
			var suggested_price = $('input:radio[name="product_id"]:checked').next().next().val();
			$('#product_id').val(item);
			$('#product_name').val(name);
			$('#estimate_price').val(suggested_price);
			$('#sales_price').val(suggested_price);
			$('#amount').val(1);
            $(this).dialog("close");  
        },
		"Cancel": function () {
            $(this).dialog("close");
        }
    }
});
$("#product_name").click(function(){
	$('#dialog-select').dialog('open');
	$('#dialog-select').load('{:U("product/allproductdialog")}');
});
</script>
<form action="{:U('product/addDialog')}" method="post">
	<input type="hidden" name="creator_role_id" value="{$Think.session.role_id}"/>
	<input type="hidden" name="r" value="{$r}"/>
	<input type="hidden" name="module" value="{$module}"/>
	<input type="hidden" name="model_id" value="{$model_id}"/>
	<input type="hidden" name="dialog_add" value="dialog_add"/>
	<table class="table table-hover">
		<tfoot>
			<tr>
				<th>&nbsp;</th>
				<th colspan="3"><input class="btn btn-primary" type="submit" value="{:L('SAVE')}"/> &nbsp;<input class="btn" onclick="javascript:$('#dialog-product').dialog('close');" type="button" value="{:L('CANCEL')}"/></th>
			</tr>
		</tfoot>
		<tbody>
			<tr><th <if condition="C('ismobile') neq 1">colspan="4"<else />colspan="2"</if>>{:L('BASIC_INFORMATION')}</th></tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('PRODUCT')}</td>
				<td valign="middle"><input type="hidden" name="product_id" id="product_id"/><input name="product_name" id="product_name" type="text" /></td>
				<if condition="C('ismobile') eq 1"></tr><tr></if>
				<td class="tdleft" valign="middle">{:L('OFFER')}</td>
				<td valign="middle">
					<input name="estimate_price" id="estimate_price" type="text" />
				</td>
			</tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('SELLING_PRICE')}</td>
				<td valign="middle"><input name="sales_price" id="sales_price" type="text" /></td>
				<if condition="C('ismobile') eq 1"></tr><tr></if>
				<td class="tdleft" valign="middle">{:L('QUANTITY')}</td>
				<td valign="middle"><input name="amount" id="amount" type="text" /></td>
			</tr>
			<tr>
				<td class="tdleft" valign="middle">{:L('REMARK')}</td>
				<td <if condition="C('ismobile') neq 1">colspan="3"</if> valign="middle"><textarea rows="6" class="span5" name="description"></textarea></td>
			</tr>
		</tbody>
	</table>
</form>
<div class="hide" id="dialog-select" title="{:L('ADD_PRODUCT')}">loading...</div>
